package com.bigegg.employee.service.impl;

import java.util.List;

import com.bigegg.employee.dto.ActSignDetail;
import com.bigegg.employee.dto.MajorActSignSta;
import com.bigegg.employee.dto.StuSign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bigegg.employee.mapper.ActivitySignMapper;
import com.bigegg.employee.domain.ActivitySign;
import com.bigegg.employee.service.IActivitySignService;

/**
 * 活动签到Service业务层处理
 *
 * @author sun
 * @date 2022-08-16
 */
@Service
public class ActivitySignServiceImpl implements IActivitySignService {
    @Autowired
    private ActivitySignMapper activitySignMapper;

    /**
     * 查询活动签到
     *
     * @param id 活动签到主键
     * @return 活动签到
     */
    @Override
    public ActivitySign selectActivitySignById(Long id) {
        return activitySignMapper.selectActivitySignById(id);
    }

    /**
     * 查询活动签到列表
     *
     * @param activitySign 活动签到
     * @return 活动签到
     */
    @Override
    public List<ActivitySign> selectActivitySignList(ActivitySign activitySign) {
        return activitySignMapper.selectActivitySignList(activitySign);
    }

    /**
     * 新增活动签到
     *
     * @param activitySign 活动签到
     * @return 结果
     */
    @Override
    public int insertActivitySign(ActivitySign activitySign) {
        return activitySignMapper.insertActivitySign(activitySign);
    }

    /**
     * 修改活动签到
     *
     * @param activitySign 活动签到
     * @return 结果
     */
    @Override
    public int updateActivitySign(ActivitySign activitySign) {
        return activitySignMapper.updateActivitySign(activitySign);
    }

    /**
     * 批量删除活动签到
     *
     * @param ids 需要删除的活动签到主键
     * @return 结果
     */
    @Override
    public int deleteActivitySignByIds(Long[] ids) {
        return activitySignMapper.deleteActivitySignByIds(ids);
    }

    /**
     * 删除活动签到信息
     *
     * @param id 活动签到主键
     * @return 结果
     */
    @Override
    public int deleteActivitySignById(Long id) {
        return activitySignMapper.deleteActivitySignById(id);
    }

    @Override
    public boolean hasSigned(Long stuId, Long actId) {
        return activitySignMapper.hasSigned(stuId, actId) > 0;
    }

    /**
     * 活动所有签到数
     *
     * @param activityId 活动ID
     * @return 签到数
     */
    public int getCountSign(Long activityId) {
        return activitySignMapper.countSign(activityId);
    }

    /**
     * 获取活动班级签到数
     *
     * @param activityId  活动
     * @param classIdList 班级list
     * @return 签到数
     */
    public int getCountClassSign(Long activityId, List<Long> classIdList) {
        return activitySignMapper.countClassSign(activityId, classIdList);
    }

    /**
     * 查询专业签到情况
     *
     * @param actId  活动ID
     * @param deptId 部门ID
     */
    public List<MajorActSignSta> getCountMajorSign(Long actId, Long deptId) {
        return activitySignMapper.countMajorSign(actId, deptId);
    }

    /**
     * 查询所有签到情况
     */
    public List<ActSignDetail> getActivitySignDetail() {
        return activitySignMapper.getActSignDetail();
    }

    /**
     * 获取班级签到情况
     *
     * @param activity_id 活动ID
     * @param collect     班级ID list
     */
    public List<StuSign> getClassDetail(Long activity_id, Long collect) {
        return activitySignMapper.getClassDetail(activity_id, collect);
    }
}
